<?php
	header('Content-Type:text/html;charset=utf-8');
   $servern="localhost";
   $coninfo=array("Database"=>"CNZZ_new","UID"=>"sa","PWD"=>"1111");
   $conn=sqlsrv_connect($servern,$coninfo); //or die ("连接失败!");
   if($conn){
	   echo "sql数据库连接成功！<br>";
   }else{
	   echo "连接失败！<br>";
   }
   
   $table_name = "CNZZWZ";
	/*如果你的数据库表名是中文，记得加上这句：*/
	//$table_name = iconv("UTF-8", "GB2312", "中文表名");
	/*query语句：*/
	$rs=sqlsrv_query($conn, "select top 30 * from ".$table_name);
	  
	if($rs == false){
	echo("false<br>");
	}else{
		echo "<table>";
                
	while($row = sqlsrv_fetch_array($rs)){
		//print_r($row);
            $se=iconv('GB2312', 'UTF-8', $row[1]);
            $sa=iconv('GB2312', 'UTF-8', $row[4]);
            $sb=iconv('GB2312', 'UTF-8', $row[5]);
		echo "<tr><td>$se</td><td>$sa</td><td>$sb</td></tr>";
	}
		echo "</table>";
	sqlsrv_free_stmt($rs);
	sqlsrv_close($conn);
	}

?> 

